local lu = require 'luaunit'
local c_drive = require 'drive.drive_object'
local c_storageconfig = require 'storageconfig.storageconfig_object'

TEST_Drive_Object = {}
function TEST_Drive_Object:test_monitor_fault_state()
    local config = c_storageconfig.new({bus = 0, db = 1})
    config.all_ctrl_loaded = false
    local obj = {
        new_task = function(...) return {
            loop = function(obj, cb)
                cb(1)
                return {set_timeout_ms = function(...) return end}
            end
        } end,
        Protocol = 3,
        RefControllerId = 0,
        Presence = 0,
        LocateLed = 0,
        FaultLed = 1,
        InAFailedArray = 2,
        cont_bin = {
            get_debounced_val = function(i, n) return n end
        },
        FirmwareStatusError = true
    }
    c_drive.monitor_fault_state(obj)
    lu.assertEquals(obj.InAFailedArray, 1)
    obj.Presence = 1
    c_drive.monitor_fault_state(obj)
    lu.assertEquals(obj.InAFailedArray, 0)
end
